<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        button{
            width: 60px;
            height: 40px;
            border: 1px solid grey;
            color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="input-num">
        <!--    下面是语法糖写法-->
        <button @click="sub">-</button>
        <span>{{ num }}</span>
        <button @click="add">+</button>
    </div>
</div>
<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el:"#app",
        data:{
            num:1,
        },
        methods:{
            add:function (){
                if(this.num < 10){
                    this.num++;
                }else {
                    alert("别点了，最大了")
                }
            },
            sub:function (){
                if(this.num > 0) {
                    this.num--;
                }else{
                    alert("别点了，最小了")
                }
            }
        },
    })
</script>
</body>
</html>